﻿// <copyright file="DeityExporter.cs" company="Gravity Age Studios">
// Code released under the MIT license (see License.txt).
// </copyright>
// <author>Vicente Cartas Espinel</author>
// <email>vicente.cartas@gmail.com</email>
namespace LightSwitchApplication.Export
{
    using System.IO;
    using Microsoft.LightSwitch.Framework.Client;

    public class DeityExporter : IExporter<Deity>
    {
        public void WriteHeaders(StreamWriter stream)
        {
            stream.WriteLine("Visibility;Name;Abbr;Type;Alignment;Public Information;GM Information");
        }

        public void ExportData(StreamWriter stream, VisualCollection<Deity> collection)
        {
            foreach (var deity in collection)
            {
                stream.WriteLine(string.Format("{0};{1};{2};{3};{4};{5};{6}",
                    deity.Visibility,
                    deity.Name != null ? deity.Name.Replace(";", ".") : string.Empty,
                    deity.Abbreviation != null ? deity.Abbreviation.Replace(";", ".") : string.Empty,
                    deity.Type,
                    deity.Alignment != null ? deity.Alignment.Name.Replace(";", ".") : string.Empty,
                    deity.PublicInformation != null ? deity.PublicInformation.Replace(";", ".") : string.Empty,
                    deity.GMInformation != null ? deity.GMInformation.Replace(";", ".") : string.Empty));
            }
        }
    }
}
